<html>
<head>
<meta charset="utf-8">
<title>tree-ul-li</title>
<link rel="stylesheet" type="text/css" href="jdtree.css">
<style>
html,body{margin:0;padding:0;}
</style>
</head>

<body style="background:#fff">
    <ul class="jdul-tree" id="jdul_tree">
        <!-- <li class="has-child"><i></i><span>主动安全1</span>
            <ul><li><span>前向碰撞1-1</span></li><li><span>睡觉报警1-2</span></li><li><span>睡觉报警1-3</span></li></ul>
        </li>
        <li class="has-child is-opened"><span><i></i>主动安全2</span>
            <ul><li><span>前向碰撞2-1</span></li><li><span>睡觉报警2-2</span></li></ul>
        </li> -->
    </ul>
	<button id="getbtn">获取</button>
	<div id="idsarr"></div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
 <script src="jdtree.js"></script>
<script type="text/javascript">
	$(function(){
	    let typearr = [{
	            code:1,
	            name:'主动安全1',
	            disabled: false,
	            hasChild: true,
	            isOpened: true,
	            child:[{
	                code:11,
	                name:'前向碰撞1-1',
	                disabled: false,
	                hasChild: false,
	                isOpened: true,
	                child:[{
	                    code:111,
	                    name:'前向碰撞1-1-1',
	                    disabled: false,
	                    hasChild: true,
	                    isOpened:true,
	                    child:[{
	                    	code:1111,
	                    	name:'前向碰撞1-1-1-1',
	                    	disabled: false,
	                    	hasChild: false
	                    }]
	                },{
	                    code:112,
	                    name:'前向碰撞1-1-2',
	                    disabled: false,
	                    hasChild: false, }]
	                },{
	                code:12,
	                name:'前向碰撞1-2',
	                disabled: false,
	                hasChild: false, }]
	        },{
	            code:2,
	            name:'主动安全2',
	            hasChild: true,
	            isOpened: true,
	            child:[{
	                code:21,
	                name:'ba21',
	            	hasChild: true,
		            isOpened: true,
		            child:[{
		                code:211,
		                name:'ba211',
		                hasChild: false},{
		                code:212,
		                name:'ba212',
		                hasChild: false}]}]
	        }]
	    jdtree.init(typearr);
	    jdtree.setChecked(`1111`)
	 	$("#getbtn").click(() => {
	 		$("#idsarr").text(jdtree.getCheckNames())
	 		console.log(jdtree.getCheckIds())
	 	})
	});
</script>

</body>
</html>
